package Dungeoneering.Keys;

/**
 * This is the Color of a key: see Key
 * @author Nicolaas
 *
 */
public enum KeyColor {
	
	// ID's of key items in order of color and shape. order being or, si, ye, gr, bl, pu, cri, go -- and tri, di, re, pe, co, cre, we, sh
	ORANGE ("Orange"),
	SILVER ("Silver"),
	YELLOW ("Yellow"),
	GREEN ("Green"),
	BLUE ("Blue"),
	PURPLE ("Purple"),
	CRIMSON ("Crimson"),
	GOLD ("Gold");
	
	private final String name;
	
	private final static int FIRST_KEY = 18202; // orange triangle
	private final static int LAST_KEY = 18328; // gold shield
	
	private final static int FRO_FIRST_KEYDOOR = 50353;
	private final static int FUR_FIRST_KEYDOOR = 50481;
	private final static int ABA_FIRST_KEYDOOR = 50417;
	private final static int OCC_FIRST_KEYDOOR = 53884;
	private final static int WARP_FIRST_KEYDOOR = 55675;
	
	KeyColor(String name) {
		this.name = name;
	}
	
	/**
	 * gets the name of the KeyColor
	 * @return the Name
	 */
	public String getName() {
		return name;
	}
	
	/**
	 * checks if the item id is indeed a key
	 * @param id the id of the item
	 * @return true if it's a key
	 */
	public static boolean isKey(int id) {
		return (id >= FIRST_KEY && id <= LAST_KEY);
	}
	
	
	/**
	 * finds the color of the key
	 * @param id the itemId
	 * @return the Color of the key
	 */
	public static KeyColor getKeyFromItem(int id) {
		id -= FIRST_KEY;
		if (id < 16)
			return ORANGE;
		if (id < 32)
			return SILVER;
		if (id < 48)
			return YELLOW;
		if (id < 64)
			return GREEN;
		if (id < 80)
			return BLUE;
		if (id < 96)
			return PURPLE;
		if (id < 112)
			return CRIMSON;
		return GOLD;
	}
}
